<template>
  <div>
    <el-row :gutter="15">
      <el-form ref="elForm" :model="dataForm" :rules="dataRule" size="small" label-width="100px" label-position="top"
               :disabled="setting.readonly">
        <template v-if="!loading && formOperates">
          <el-col :span="24">
            <!--            finish-status="success"-->
            <el-steps class="steps" simple process-status="process" :active="currentTab" align-center>
              <el-step title="基础信息" @click.native="stepChick(0)" style="cursor: pointer "/>
              <el-step title="权证信息" @click.native="stepChick(1)" style="cursor: pointer "/>
              <el-step title="面积及可租信息" @click.native="stepChick(2)" style="cursor: pointer "/>
            </el-steps>
            <div v-show="currentTab === 0">
              <el-col :span="6" v-if="judgeShow('assetCode')">
                <el-form-item label="资产编码"
                              prop="assetCode">
                  <el-input v-model="dataForm.assetCode"
                            placeholder="系统自动生成" :disabled="judgeWrite('assetCode')">
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="judgeShow('assetName')"
              >
                <el-form-item label="资产名称"
                              prop="assetName">
                  <el-input v-model="dataForm.assetName"
                            placeholder="请输入" :disabled="judgeWrite('assetName')" clearable :style='{"width":"100%"}'>

                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="judgeShow('assetTags')"
              >
                <el-form-item label="资产标签"
                              prop="assetTags">
                  <el-input v-model="dataForm.assetTags"
                            placeholder="请输入" :disabled="judgeWrite('assetTags')" clearable :style='{"width":"100%"}'>

                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12" v-if="judgeShow('detailedAddress')"
              >
                <el-form-item label="详细地址"
                              prop="detailedAddress">
                  <el-input v-model="dataForm.detailedAddress"
                            placeholder="请输入" :disabled="judgeWrite('detailedAddress')" clearable
                            :style='{"width":"100%"}'>

                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="judgeShow('assetNature')"
              >
                <el-form-item label="资产性质"
                              prop="assetNature">
                  <el-select v-model="dataForm.assetNature"
                             placeholder="请选择" :disabled="judgeWrite('assetNature')" clearable
                             :style='{"width":"100%"}'>
                    <el-option v-for="(item, index) in assetNatureOptions" :key="index" :label="item.fullName"
                               :value="item.id" :disabled="item.disabled"></el-option>

                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="judgeShow('assetUse')"
              >
                <el-form-item label="资产用途"
                              prop="assetUse">
                  <el-select v-model="dataForm.assetUse"
                             placeholder="请选择" :disabled="judgeWrite('assetUse')" clearable :style='{"width":"100%"}'>
                    <el-option v-for="(item, index) in assetUseOptions" :key="index" :label="item.fullName"
                               :value="item.id" :disabled="item.disabled"></el-option>

                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="judgeShow('assetSource')"
              >
                <el-form-item label="资产来源"
                              prop="assetSource">
                  <el-select v-model="dataForm.assetSource"
                             placeholder="请选择" :disabled="judgeWrite('assetSource')" clearable
                             :style='{"width":"100%"}'>
                    <el-option v-for="(item, index) in assetSourceOptions" :key="index" :label="item.fullName"
                               :value="item.id" :disabled="item.disabled"></el-option>

                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="judgeShow('propertyRightUnit')"
              >
                <el-form-item label="权属单位"
                              prop="propertyRightUnit">
                  <el-select v-model="dataForm.propertyRightUnit"
                             placeholder="请选择" :disabled="judgeWrite('propertyRightUnit')" clearable
                             :style='{"width":"100%"}'>
                    <el-option v-for="(item, index) in propertyRightUnitOptions" :key="index" :label="item.fullName"
                               :value="item.id" :disabled="item.disabled"></el-option>

                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="judgeShow('managementUnit')"
              >
                <el-form-item label="管理单位"
                              prop="managementUnit">
                  <el-select v-model="dataForm.managementUnit"
                             placeholder="请选择" :disabled="judgeWrite('managementUnit')" clearable
                             :style='{"width":"100%"}'>
                    <el-option v-for="(item, index) in managementUnitOptions" :key="index" :label="item.fullName"
                               :value="item.id" :disabled="item.disabled"></el-option>

                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="judgeShow('managerId')"
              >
                <el-form-item label="资产管理员"
                              prop="managerId">
                  <user-select v-model="dataForm.managerId"
                               placeholder="请选择" :disabled="judgeWrite('managerId')" clearable>

                  </user-select>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="judgeShow('coverPictureUrl')"
              >
                <el-form-item label="资产封面上传"
                              prop="coverPictureUrl">
                  <JNPF-UploadImg v-model="dataForm.coverPictureUrl"
                                  :fileSize="10" :disabled="judgeWrite('coverPictureUrl')" sizeUnit="MB" :limit="1">

                  </JNPF-UploadImg>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="judgeShow('remark')"
              >
                <el-form-item label="备注"
                              prop="remark">
                  <el-input v-model="dataForm.remark"
                            placeholder="请输入" :maxlength="500" :disabled="judgeWrite('remark')"
                            :style='{"width":"100%"}' true type="textarea" :autosize='{"minRows":7,"maxRows":7}'>

                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="judgeShow('attachmentUrls')"
              >
                <el-form-item label="附件"
                              prop="attachmentUrls">
                  <JNPF-UploadFz v-model="dataForm.attachmentUrls"
                                 :fileSize="10" :disabled="judgeWrite('attachmentUrls')" sizeUnit="MB" :limit="9"
                                 buttonText="上传附件">

                  </JNPF-UploadFz>
                </el-form-item>
              </el-col>
            </div>
            <div v-show="currentTab === 1" label="权证信息">
              <el-col :span="6" v-if="judgeShow('jnpf_zc_asset_warrant_jnpf_type')"
              >
                <el-form-item label="产权性质"
                              prop="jnpf_zc_asset_warrant_jnpf_type">
                  <el-select v-model=" dataForm.jnpf_zc_asset_warrant_jnpf_type"
                             placeholder="请选择" :disabled="judgeWrite('jnpf_zc_asset_warrant_jnpf_type')" clearable
                             :style='{"width":"100%"}'>
                    <el-option v-for="(item, index) in jnpf_zc_asset_warrant_jnpf_typeOptions" :key="index"
                               :label="item.fullName" :value="item.id" :disabled="item.disabled"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="judgeShow('jnpf_zc_asset_warrant_jnpf_code')"
              >
                <el-form-item label="权证号"
                              prop="jnpf_zc_asset_warrant_jnpf_code">
                  <el-input v-model=" dataForm.jnpf_zc_asset_warrant_jnpf_code"
                            placeholder="请输入" :disabled="judgeWrite('jnpf_zc_asset_warrant_jnpf_code')" clearable
                            :style='{"width":"100%"}'>
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="judgeShow('jnpf_zc_asset_warrant_jnpf_landUse')"
              >
                <el-form-item label="证载土地用途"
                              prop="jnpf_zc_asset_warrant_jnpf_landUse">
                  <el-input v-model=" dataForm.jnpf_zc_asset_warrant_jnpf_landUse"
                            placeholder="请输入" :disabled="judgeWrite('jnpf_zc_asset_warrant_jnpf_landUse')" clearable
                            :style='{"width":"100%"}'>
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="judgeShow('jnpf_zc_asset_warrant_jnpf_roomUse')"
              >
                <el-form-item label="证载房屋用途"
                              prop="jnpf_zc_asset_warrant_jnpf_roomUse">
                  <el-input v-model=" dataForm.jnpf_zc_asset_warrant_jnpf_roomUse"
                            placeholder="请输入" :disabled="judgeWrite('jnpf_zc_asset_warrant_jnpf_roomUse')" clearable
                            :style='{"width":"100%"}'>
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="judgeShow('jnpf_zc_asset_warrant_jnpf_propertyUse')"
              >
                <el-form-item label="证载产权人"
                              prop="jnpf_zc_asset_warrant_jnpf_propertyUse">
                  <el-input v-model=" dataForm.jnpf_zc_asset_warrant_jnpf_propertyUse"
                            placeholder="请输入" :disabled="judgeWrite('jnpf_zc_asset_warrant_jnpf_propertyUse')"
                            clearable :style='{"width":"100%"}'>
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="judgeShow('jnpf_zc_asset_warrant_jnpf_certifiedAddress')"
              >
                <el-form-item label="证载地址"
                              prop="jnpf_zc_asset_warrant_jnpf_certifiedAddress">
                  <el-input v-model=" dataForm.jnpf_zc_asset_warrant_jnpf_certifiedAddress"
                            placeholder="请输入" :disabled="judgeWrite('jnpf_zc_asset_warrant_jnpf_certifiedAddress')"
                            clearable :style='{"width":"100%"}'>
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="judgeShow('jnpf_zc_asset_warrant_jnpf_nowPropertyUse')"
              >
                <el-form-item label="现状产权人"
                              prop="jnpf_zc_asset_warrant_jnpf_nowPropertyUse">
                  <el-input v-model=" dataForm.jnpf_zc_asset_warrant_jnpf_nowPropertyUse"
                            placeholder="请输入" :disabled="judgeWrite('jnpf_zc_asset_warrant_jnpf_nowPropertyUse')"
                            clearable :style='{"width":"100%"}'>
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="judgeShow('jnpf_zc_asset_warrant_jnpf_landAuthorityNature')"
              >
                <el-form-item label="土地使用权性质"
                              prop="jnpf_zc_asset_warrant_jnpf_landAuthorityNature">
                  <el-select v-model=" dataForm.jnpf_zc_asset_warrant_jnpf_landAuthorityNature"
                             placeholder="请选择"
                             :disabled="judgeWrite('jnpf_zc_asset_warrant_jnpf_landAuthorityNature')" clearable
                             :style='{"width":"100%"}'>
                    <el-option v-for="(item, index) in jnpf_zc_asset_warrant_jnpf_landAuthorityNatureOptions"
                               :key="index" :label="item.fullName" :value="item.id"
                               :disabled="item.disabled"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="judgeShow('jnpf_zc_asset_warrant_jnpf_numberOblocks')"
              >
                <el-form-item label="幢数"
                              prop="jnpf_zc_asset_warrant_jnpf_numberOblocks">
                  <el-input-number v-model=" dataForm.jnpf_zc_asset_warrant_jnpf_numberOblocks"
                                   placeholder="数字文本"
                                   :disabled="judgeWrite('jnpf_zc_asset_warrant_jnpf_numberOblocks')" :step="1">
                  </el-input-number>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="judgeShow('jnpf_zc_asset_warrant_jnpf_generalFloor')"
              >
                <el-form-item label="总楼层"
                              prop="jnpf_zc_asset_warrant_jnpf_generalFloor">
                  <el-input-number v-model=" dataForm.jnpf_zc_asset_warrant_jnpf_generalFloor"
                                   placeholder="数字文本"
                                   :disabled="judgeWrite('jnpf_zc_asset_warrant_jnpf_generalFloor')" :step="1">
                  </el-input-number>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="judgeShow('jnpf_zc_asset_warrant_jnpf_floorNum')"
              >
                <el-form-item label="所在楼层"
                              prop="jnpf_zc_asset_warrant_jnpf_floorNum">
                  <el-input-number v-model=" dataForm.jnpf_zc_asset_warrant_jnpf_floorNum"
                                   placeholder="数字文本" :disabled="judgeWrite('jnpf_zc_asset_warrant_jnpf_floorNum')"
                                   :step="1">
                  </el-input-number>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="judgeShow('jnpf_zc_asset_warrant_jnpf_startDate')"
              >
                <el-form-item label="开始使用日期"
                              prop="jnpf_zc_asset_warrant_jnpf_startDate">
                  <el-date-picker v-model=" dataForm.jnpf_zc_asset_warrant_jnpf_startDate"
                                  placeholder="请选择" :disabled="judgeWrite('jnpf_zc_asset_warrant_jnpf_startDate')"
                                  clearable :style='{"width":"100%"}' type="date" format="yyyy-MM-dd"
                                  value-format="timestamp">
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="judgeShow('jnpf_zc_asset_warrant_jnpf_endDate')"
              >
                <el-form-item label="使用到期日期"
                              prop="jnpf_zc_asset_warrant_jnpf_endDate">
                  <el-date-picker v-model=" dataForm.jnpf_zc_asset_warrant_jnpf_endDate"
                                  placeholder="请选择" :disabled="judgeWrite('jnpf_zc_asset_warrant_jnpf_endDate')"
                                  clearable :style='{"width":"100%"}' type="date" format="yyyy-MM-dd"
                                  value-format="timestamp">
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="judgeShow('jnpf_zc_asset_warrant_jnpf_issueDate')"
              >
                <el-form-item label="发证日期"
                              prop="jnpf_zc_asset_warrant_jnpf_issueDate">
                  <el-date-picker v-model=" dataForm.jnpf_zc_asset_warrant_jnpf_issueDate"
                                  placeholder="请选择" :disabled="judgeWrite('jnpf_zc_asset_warrant_jnpf_issueDate')"
                                  clearable :style='{"width":"100%"}' type="date" format="yyyy-MM-dd"
                                  value-format="timestamp">
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="judgeShow('jnpf_zc_asset_warrant_jnpf_custodyPlace')"
              >
                <el-form-item label="产权证保管地"
                              prop="jnpf_zc_asset_warrant_jnpf_custodyPlace">
                  <el-input v-model=" dataForm.jnpf_zc_asset_warrant_jnpf_custodyPlace"
                            placeholder="请输入" :disabled="judgeWrite('jnpf_zc_asset_warrant_jnpf_custodyPlace')"
                            clearable :style='{"width":"100%"}'>
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12" v-if="judgeShow('jnpf_zc_asset_warrant_jnpf_remark')"
              >
                <el-form-item label="备注"
                              prop="jnpf_zc_asset_warrant_jnpf_remark">
                  <el-input v-model=" dataForm.jnpf_zc_asset_warrant_jnpf_remark"
                            placeholder="请输入" :maxlength="500"
                            :disabled="judgeWrite('jnpf_zc_asset_warrant_jnpf_remark')" :style='{"width":"100%"}' true
                            type="textarea" :autosize='{"minRows":4,"maxRows":4}'>
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6" v-if="judgeShow('jnpf_zc_asset_warrant_jnpf_attachmentUrls')"
              >
                <el-form-item label="产权证附件"
                              prop="jnpf_zc_asset_warrant_jnpf_attachmentUrls">
                  <JNPF-UploadFz v-model=" dataForm.jnpf_zc_asset_warrant_jnpf_attachmentUrls"
                                 :fileSize="10" :disabled="judgeWrite('jnpf_zc_asset_warrant_jnpf_attachmentUrls')"
                                 sizeUnit="MB" :limit="9" buttonText="上传附件">
                  </JNPF-UploadFz>
                </el-form-item>
              </el-col>
              <el-col :span="24" v-if="judgeShow('jnpf_zc_asset_warrant_jnpf_imageUrl')"
              >
                <el-form-item label="产权证图片"
                              prop="jnpf_zc_asset_warrant_jnpf_imageUrl">
                  <JNPF-UploadImg v-model=" dataForm.jnpf_zc_asset_warrant_jnpf_imageUrl"
                                  :fileSize="10" :disabled="judgeWrite('jnpf_zc_asset_warrant_jnpf_imageUrl')"
                                  sizeUnit="MB" :limit="9">
                  </JNPF-UploadImg>
                </el-form-item>
              </el-col>
            </div>
            <div v-show="currentTab === 2" label="面积及可租信息">
              <el-col :span="12" v-if="judgeShow('jnpf_zc_asset_area_jnpf_floorArea')"
              >
                <el-form-item label="建筑面积"
                              prop="jnpf_zc_asset_area_jnpf_floorArea">
                  <el-input v-model=" dataForm.jnpf_zc_asset_area_jnpf_floorArea"
                            placeholder="请输入" :disabled="judgeWrite('jnpf_zc_asset_area_jnpf_floorArea')" clearable
                            :style='{"width":"100%"}'>
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12" v-if="judgeShow('jnpf_zc_asset_area_jnpf_casingArea')"
              >
                <el-form-item label="套内面积"
                              prop="jnpf_zc_asset_area_jnpf_casingArea">
                  <el-input v-model=" dataForm.jnpf_zc_asset_area_jnpf_casingArea"
                            placeholder="请输入" :disabled="judgeWrite('jnpf_zc_asset_area_jnpf_casingArea')" clearable
                            :style='{"width":"100%"}'>
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12" v-if="judgeShow('jnpf_zc_asset_area_jnpf_commonArea')"
              >
                <el-form-item label="公摊面积"
                              prop="jnpf_zc_asset_area_jnpf_commonArea">
                  <el-input v-model=" dataForm.jnpf_zc_asset_area_jnpf_commonArea"
                            placeholder="请输入" :disabled="judgeWrite('jnpf_zc_asset_area_jnpf_commonArea')" clearable
                            :style='{"width":"100%"}'>
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12" v-if="judgeShow('jnpf_zc_asset_area_jnpf_leasableArea')"
              >
                <el-form-item label="可租面积"
                              prop="jnpf_zc_asset_area_jnpf_leasableArea">
                  <el-input v-model=" dataForm.jnpf_zc_asset_area_jnpf_leasableArea"
                            placeholder="请输入" :disabled="judgeWrite('jnpf_zc_asset_area_jnpf_leasableArea')" clearable
                            :style='{"width":"100%"}'>
                  </el-input>
                </el-form-item>
              </el-col>
            </div>
            <!--              <el-tab-pane label="资产近照">-->
            <!--                <el-col :span="24" v-if="judgeShow('jnpf_zc_asset_image_jnpf_imageDate')"-->
            <!--                >-->
            <!--                  <el-form-item label="近照日期"-->
            <!--                                prop="jnpf_zc_asset_image_jnpf_imageDate">-->
            <!--                    <el-date-picker v-model=" dataForm.jnpf_zc_asset_image_jnpf_imageDate"-->
            <!--                                    placeholder="请选择" :disabled="judgeWrite('jnpf_zc_asset_image_jnpf_imageDate')"-->
            <!--                                    clearable :style='{"width":"100%"}' type="date" format="yyyy-MM-dd"-->
            <!--                                    value-format="timestamp">-->
            <!--                    </el-date-picker>-->
            <!--                  </el-form-item>-->
            <!--                </el-col>-->
            <!--                <el-col :span="24" v-if="judgeShow('jnpf_zc_asset_image_jnpf_imageUrl')"-->
            <!--                >-->
            <!--                  <el-form-item label="资产近照"-->
            <!--                                prop="jnpf_zc_asset_image_jnpf_imageUrl">-->
            <!--                    <JNPF-UploadImg v-model=" dataForm.jnpf_zc_asset_image_jnpf_imageUrl"-->
            <!--                                    :fileSize="10" :disabled="judgeWrite('jnpf_zc_asset_image_jnpf_imageUrl')"-->
            <!--                                    sizeUnit="MB" :limit="9">-->
            <!--                    </JNPF-UploadImg>-->
            <!--                  </el-form-item>-->
            <!--                </el-col>-->
            <!--              </el-tab-pane>-->
          </el-col>

<!--          <el-col :span="24" style="text-align: center">-->
<!--              <el-button type="primary" icon="el-icon-plus" v-has="'btn_add'" @click="addOrUpdateHandle()">新增 </el-button>-->
<!--              <el-button type="primary" icon="el-icon-plus" v-has="'btn_add'" @click="addOrUpdateHandle()">新增 </el-button>-->
<!--          </el-col>-->
        </template>
      </el-form>
    </el-row>
    <UserBox v-if="userBoxVisible" ref="userBox" @submit="submit"/>
  </div>
</template>
<script>
import request from '@/utils/request'
import {getDataInterfaceRes} from '@/api/systemData/dataInterface'
import {getDictionaryDataSelector} from '@/api/systemData/dictionary'

export default {
  components: {},
  props: [],
  data() {
    return {
      visible: false,
      loading: false,
      setting: {},
      eventType: '',
      currentTab: 0,
      userBoxVisible: false,
      currTableConf: {},
      addTableConf: {},
      tableRows: {},
      dataForm: {
        id: '',
        flowId: '',
        status: 1,
        freeapproveruserid: '',
        flowUrgent: 1,
        assetCode: undefined,
        assetName: undefined,
        assetTags: undefined,
        detailedAddress: undefined,
        assetNature: undefined,
        assetUse: undefined,
        assetSource: undefined,
        propertyRightUnit: undefined,
        managementUnit: undefined,
        managerId: undefined,
        coverPictureUrl: [],
        remark: undefined,
        attachmentUrls: [],
        zc_asset_warrant:
          {
            type: '',
            code: '',
            landUse: '',
            roomUse: '',
            propertyUse: '',
            certifiedAddress: '',
            nowPropertyUse: '',
            landAuthorityNature: '',
            numberOblocks: '',
            generalFloor: '',
            floorNum: '',
            startDate: '',
            endDate: '',
            issueDate: '',
            custodyPlace: '',
            remark: '',
            attachmentUrls: '',
            imageUrl: '',
          },
        zc_asset_area:
          {
            floorArea: '',
            casingArea: '',
            commonArea: '',
            leasableArea: '',
          },
        zc_asset_image:
          {
            imageDate: '',
            imageUrl: '',
          },
        jnpf_zc_asset_warrant_jnpf_type: "",
        jnpf_zc_asset_warrant_jnpf_code: '',
        jnpf_zc_asset_warrant_jnpf_landUse: '',
        jnpf_zc_asset_warrant_jnpf_roomUse: '',
        jnpf_zc_asset_warrant_jnpf_propertyUse: '',
        jnpf_zc_asset_warrant_jnpf_certifiedAddress: '',
        jnpf_zc_asset_warrant_jnpf_nowPropertyUse: '',
        jnpf_zc_asset_warrant_jnpf_landAuthorityNature: "",
        jnpf_zc_asset_warrant_jnpf_numberOblocks: '',
        jnpf_zc_asset_warrant_jnpf_generalFloor: '',
        jnpf_zc_asset_warrant_jnpf_floorNum: 0,
        jnpf_zc_asset_warrant_jnpf_startDate: '',
        jnpf_zc_asset_warrant_jnpf_endDate: '',
        jnpf_zc_asset_warrant_jnpf_issueDate: '',
        jnpf_zc_asset_warrant_jnpf_custodyPlace: '',
        jnpf_zc_asset_warrant_jnpf_remark: '',
        jnpf_zc_asset_warrant_jnpf_attachmentUrls: [],
        jnpf_zc_asset_warrant_jnpf_imageUrl: [],
        jnpf_zc_asset_area_jnpf_floorArea: '',
        jnpf_zc_asset_area_jnpf_casingArea: '',
        jnpf_zc_asset_area_jnpf_commonArea: '',
        jnpf_zc_asset_area_jnpf_leasableArea: '',
        jnpf_zc_asset_image_jnpf_imageDate: '',
        jnpf_zc_asset_image_jnpf_imageUrl: [],
        version: 0,
      },
      tableRequiredData: {},
      activeseldjz: '0',
      dataRule:
        {
          assetName: [
            {
              required: true,
              message: '请输入',
              trigger: 'blur'
            },
          ],
          detailedAddress: [
            {
              required: true,
              message: '请输入',
              trigger: 'blur'
            },
          ],
          assetNature: [
            {
              required: true,
              message: '请选择',
              trigger: 'change'
            },
          ],
          assetSource: [
            {
              required: true,
              message: '请选择',
              trigger: 'change'
            },
          ],
          propertyRightUnit: [
            {
              required: true,
              message: '请选择',
              trigger: 'change'
            },
          ],
          managementUnit: [
            {
              required: true,
              message: '请选择',
              trigger: 'change'
            },
          ],


          jnpf_zc_asset_warrant_jnpf_type: [
            {
              required: true,
              message: '请选择',
              trigger: 'change'
            },
          ],
          jnpf_zc_asset_image_jnpf_imageDate: [
            {
              required: true,
              message: '请选择',
              trigger: 'change'
            },
          ],
          jnpf_zc_asset_image_jnpf_imageUrl: [
            {
              required: true,
              message: '请至少选择一个',
              trigger: 'click'
            },
          ],


        },
      assetNatureOptions: [],
      assetUseOptions: [],
      assetSourceOptions: [],
      propertyRightUnitOptions: [],
      managementUnitOptions: [],

      jnpf_zc_asset_warrant_jnpf_typeOptions: [],
      jnpf_zc_asset_warrant_jnpf_landAuthorityNatureOptions: [],
    }
  },
  computed: {
    formOperates() {
      return this.setting.formOperates
    }
  },
  watch: {},
  created() {
    this.getassetNatureOptions();
    this.getassetUseOptions();
    this.getassetSourceOptions();
    this.getpropertyRightUnitOptions();
    this.getmanagementUnitOptions();
    this.getjnpf_zc_asset_warrant_jnpf_typeOptions();
    this.getjnpf_zc_asset_warrant_jnpf_landAuthorityNatureOptions();
  },
  mounted() {
  },
  methods: {
    judgeShow(id) {
      if (!this.setting.formOperates || !this.setting.formOperates.length) return true
      let arr = this.setting.formOperates.filter(o => o.id === id) || []
      if (!arr.length) return true
      let item = arr[0]
      return item.read
    },
    stepChick(currentTab) {
      return this.currentTab = currentTab
    },
    judgeWrite(id) {
      if (!this.setting.formOperates || !this.setting.formOperates.length) return false
      let arr = this.setting.formOperates.filter(o => o.id === id) || []
      if (!arr.length) return true
      let item = arr[0]
      return !item.write
    },
    getassetNatureOptions() {
      getDictionaryDataSelector('610823452110094661').then(res => {
        this.assetNatureOptions = res.data.list
      })
    },
    getassetUseOptions() {
      getDictionaryDataSelector('610823865056100677').then(res => {
        this.assetUseOptions = res.data.list
      })
    },
    getassetSourceOptions() {
      getDictionaryDataSelector('610823965094445381').then(res => {
        this.assetSourceOptions = res.data.list
      })
    },
    getpropertyRightUnitOptions() {
      getDictionaryDataSelector('610824055188095301').then(res => {
        this.propertyRightUnitOptions = res.data.list
      })
    },
    getmanagementUnitOptions() {
      getDictionaryDataSelector('610824142995849541').then(res => {
        this.managementUnitOptions = res.data.list
      })
    },
    getjnpf_zc_asset_warrant_jnpf_typeOptions() {
      getDictionaryDataSelector('610826202277478725').then(res => {
        this.jnpf_zc_asset_warrant_jnpf_typeOptions = res.data.list
      })
    },
    getjnpf_zc_asset_warrant_jnpf_landAuthorityNatureOptions() {
      getDictionaryDataSelector('610826295164535109').then(res => {
        this.jnpf_zc_asset_warrant_jnpf_landAuthorityNatureOptions = res.data.list
      })
    },
    goBack() {
      this.$emit('refresh')
    },
    init(data) {
      this.dataForm.id = data.id || "";
      this.setting = data;
      this.visible = true;
      this.updateDataRule()
      this.$nextTick(() => {
        this.$refs['elForm'].resetFields();
        if (this.dataForm.id) {
          this.loading = true
          request({
            url: '/api/zc/zcAssetInfo/' + this.dataForm.id,
            method: 'get'
          }).then(res => {
            this.dataInfo(res.data)
            this.loading = false
          })
        }
        this.$emit('setPageLoad')
      })
      this.$store.commit('generator/UPDATE_RELATION_DATA', {})
    },
    updateDataRule() {
      let newRules = {}
      for (let i = 0; i < this.setting.formOperates.length; i++) {
        const item = this.setting.formOperates[i]
        if (!item.id.includes('-')) {
          const newRulesItem = {
            required: item.required,
            message: item.name + '不能为空',
            trigger: item.trigger || 'blur'
          }
          if (!this.dataRule.hasOwnProperty(item.id)) {
            if (item.required) this.$set(newRules, item.id, [newRulesItem])
          } else {
            let withoutRequiredItem = true
            for (let i = 0; i < this.dataRule[item.id].length; i++) {
              if (this.dataRule[item.id][i].hasOwnProperty('required')) {
                this.dataRule[item.id][i].required = item.required
                withoutRequiredItem = false
              }
            }
            if (withoutRequiredItem && item.required) this.dataRule[item.id].push(newRulesItem)
          }
        } else {
          let key = item.id.split('-')[0]
          let newId = item.id.split('-')[1]
          let newItem = {
            ...item,
            id: newId
          }
          if (!this.tableRequiredData.hasOwnProperty(key)) {
            this.$set(this.tableRequiredData, key, [newItem])
          } else {
            this.tableRequiredData[key].push(newItem)
          }
        }
      }
      this.dataRule = {...this.dataRule, ...newRules}
    },
    exist() {
      let isOk = true
      for (let key in this.tableRequiredData) {
        if (this.dataForm[key] && Array.isArray(this.dataForm[key])) {
          for (let i = 0; i < this.dataForm[key].length; i++) {
            let item = this.dataForm[key][i]
            inner: for (let id in item) {
              let arr = this.tableRequiredData[key].filter(o => o.id === id) || []
              if (!arr.length) continue inner
              if (arr[0].required) {
                let msg = `${arr[0].name}不能为空`
                let boo = true
                if (arr[0].dataType === 'array') {
                  boo = !this.jnpf.isEmptyArray(item[id])
                } else {
                  boo = !this.jnpf.isEmpty(item[id])
                }
                if (!boo) {
                  this.$message({
                    message: msg,
                    type: 'error',
                    duration: 1000
                  })
                  isOk = false
                  break
                }
              }
            }
          }
        }
      }
      return isOk
    },
    judgeRequired(id) {
      if (!this.formOperates || !this.formOperates.length) return false
      let arr = this.formOperates.filter(o => o.id === id) || []
      if (!arr.length) return false
      let item = arr[0]
      return item.required
    },
    // 表单提交
    dataFormSubmit(eventType, flowUrgent) {
      this.$refs['elForm'].validate((valid) => {
        if (valid) {
          if (this.exist && !this.exist()) return
          if (eventType === 'audit' || eventType === 'reject') {
            this.$emit('eventReceiver', this.dataForm, eventType)
            return
          }
          this.dataForm.status = eventType === 'submit' ? 0 : 1
          this.dataForm.flowId = this.setting.flowId
          this.dataForm.flowUrgent = flowUrgent
          this.eventType = eventType
          if (this.eventType === 'submit') {
            this.$confirm('您确定要提交当前流程吗, 是否继续?', '提示', {
              type: 'warning'
            }).then(() => {
              this.request()
            }).catch(() => {
            });
          } else {
            this.request()
          }
        }
      })
    },
    request() {
      var _data = this.dataList()
      if (!this.dataForm.id) {
        request({
          url: '/api/zc/zcAssetInfo',
          method: 'post',
          data: _data
        }).then((res) => {
          this.$message({
            message: res.msg,
            type: 'success',
            duration: 1000,
            onClose: () => {
              this.visible = false
              this.$emit('close', true)
            }
          })
        })
      } else {
        request({
          url: '/api/zc/zcAssetInfo/' + this.dataForm.id,
          method: 'PUT',
          data: _data
        }).then((res) => {
          this.$message({
            message: res.msg,
            type: 'success',
            duration: 1000,
            onClose: () => {
              this.visible = false
              this.$emit('close', true)
            }
          })
        })
      }
    },
    openSelectDialog(key) {
      this.currTableConf = this.addTableConf[key]
      this.currVmodel = key
      this.selectDialogVisible = true
      this.$nextTick(() => {
        this.$refs.selectDialog.init()
      })
    },
    addForSelect(data) {
      for (let i = 0; i < data.length; i++) {
        let item = {...this.tableRows[this.currVmodel], ...data[i]}
        this.dataForm[this.currVmodel].push(item)
      }
    },
    dataList() {
      var _data = JSON.parse(JSON.stringify(this.dataForm));


      _data.coverPictureUrl = JSON.stringify(_data.coverPictureUrl)


      _data.attachmentUrls = JSON.stringify(_data.attachmentUrls)

      _data.zc_asset_warrant.type = _data.jnpf_zc_asset_warrant_jnpf_type
      _data.zc_asset_warrant.code = _data.jnpf_zc_asset_warrant_jnpf_code
      _data.zc_asset_warrant.landUse = _data.jnpf_zc_asset_warrant_jnpf_landUse
      _data.zc_asset_warrant.roomUse = _data.jnpf_zc_asset_warrant_jnpf_roomUse
      _data.zc_asset_warrant.propertyUse = _data.jnpf_zc_asset_warrant_jnpf_propertyUse
      _data.zc_asset_warrant.certifiedAddress = _data.jnpf_zc_asset_warrant_jnpf_certifiedAddress
      _data.zc_asset_warrant.nowPropertyUse = _data.jnpf_zc_asset_warrant_jnpf_nowPropertyUse
      _data.zc_asset_warrant.landAuthorityNature = _data.jnpf_zc_asset_warrant_jnpf_landAuthorityNature
      _data.zc_asset_warrant.numberOblocks = _data.jnpf_zc_asset_warrant_jnpf_numberOblocks
      _data.zc_asset_warrant.generalFloor = _data.jnpf_zc_asset_warrant_jnpf_generalFloor
      _data.zc_asset_warrant.floorNum = _data.jnpf_zc_asset_warrant_jnpf_floorNum
      _data.zc_asset_warrant.startDate = _data.jnpf_zc_asset_warrant_jnpf_startDate
      _data.zc_asset_warrant.endDate = _data.jnpf_zc_asset_warrant_jnpf_endDate
      _data.zc_asset_warrant.issueDate = _data.jnpf_zc_asset_warrant_jnpf_issueDate
      _data.zc_asset_warrant.custodyPlace = _data.jnpf_zc_asset_warrant_jnpf_custodyPlace
      _data.zc_asset_warrant.remark = _data.jnpf_zc_asset_warrant_jnpf_remark
      _data.zc_asset_warrant.attachmentUrls = JSON.stringify(_data.jnpf_zc_asset_warrant_jnpf_attachmentUrls)
      _data.zc_asset_warrant.imageUrl = JSON.stringify(_data.jnpf_zc_asset_warrant_jnpf_imageUrl)
      _data.zc_asset_area.floorArea = _data.jnpf_zc_asset_area_jnpf_floorArea
      _data.zc_asset_area.casingArea = _data.jnpf_zc_asset_area_jnpf_casingArea
      _data.zc_asset_area.commonArea = _data.jnpf_zc_asset_area_jnpf_commonArea
      _data.zc_asset_area.leasableArea = _data.jnpf_zc_asset_area_jnpf_leasableArea
      _data.zc_asset_image.imageDate = _data.jnpf_zc_asset_image_jnpf_imageDate
      _data.zc_asset_image.imageUrl = JSON.stringify(_data.jnpf_zc_asset_image_jnpf_imageUrl)
      return _data;
    },
    dataInfo(dataAll) {
      let _dataAll = dataAll
      _dataAll.coverPictureUrl = JSON.parse(_dataAll.coverPictureUrl)
      _dataAll.attachmentUrls = JSON.parse(_dataAll.attachmentUrls)
      _dataAll.jnpf_zc_asset_warrant_jnpf_type = _dataAll.zc_asset_warrant.type
      _dataAll.jnpf_zc_asset_warrant_jnpf_code = _dataAll.zc_asset_warrant.code
      _dataAll.jnpf_zc_asset_warrant_jnpf_landUse = _dataAll.zc_asset_warrant.landUse
      _dataAll.jnpf_zc_asset_warrant_jnpf_roomUse = _dataAll.zc_asset_warrant.roomUse
      _dataAll.jnpf_zc_asset_warrant_jnpf_propertyUse = _dataAll.zc_asset_warrant.propertyUse
      _dataAll.jnpf_zc_asset_warrant_jnpf_certifiedAddress = _dataAll.zc_asset_warrant.certifiedAddress
      _dataAll.jnpf_zc_asset_warrant_jnpf_nowPropertyUse = _dataAll.zc_asset_warrant.nowPropertyUse
      _dataAll.jnpf_zc_asset_warrant_jnpf_landAuthorityNature = _dataAll.zc_asset_warrant.landAuthorityNature
      _dataAll.jnpf_zc_asset_warrant_jnpf_numberOblocks = _dataAll.zc_asset_warrant.numberOblocks
      _dataAll.jnpf_zc_asset_warrant_jnpf_generalFloor = _dataAll.zc_asset_warrant.generalFloor
      _dataAll.jnpf_zc_asset_warrant_jnpf_floorNum = _dataAll.zc_asset_warrant.floorNum
      _dataAll.jnpf_zc_asset_warrant_jnpf_startDate = _dataAll.zc_asset_warrant.startDate
      _dataAll.jnpf_zc_asset_warrant_jnpf_endDate = _dataAll.zc_asset_warrant.endDate
      _dataAll.jnpf_zc_asset_warrant_jnpf_issueDate = _dataAll.zc_asset_warrant.issueDate
      _dataAll.jnpf_zc_asset_warrant_jnpf_custodyPlace = _dataAll.zc_asset_warrant.custodyPlace
      _dataAll.jnpf_zc_asset_warrant_jnpf_remark = _dataAll.zc_asset_warrant.remark
      _dataAll.jnpf_zc_asset_warrant_jnpf_attachmentUrls = JSON.parse(_dataAll.zc_asset_warrant.attachmentUrls)
      _dataAll.jnpf_zc_asset_warrant_jnpf_imageUrl = JSON.parse(_dataAll.zc_asset_warrant.imageUrl)
      _dataAll.jnpf_zc_asset_area_jnpf_floorArea = _dataAll.zc_asset_area.floorArea
      _dataAll.jnpf_zc_asset_area_jnpf_casingArea = _dataAll.zc_asset_area.casingArea
      _dataAll.jnpf_zc_asset_area_jnpf_commonArea = _dataAll.zc_asset_area.commonArea
      _dataAll.jnpf_zc_asset_area_jnpf_leasableArea = _dataAll.zc_asset_area.leasableArea
      _dataAll.jnpf_zc_asset_image_jnpf_imageDate = _dataAll.zc_asset_image.imageDate
      _dataAll.jnpf_zc_asset_image_jnpf_imageUrl = JSON.parse(_dataAll.zc_asset_image.imageUrl)
      this.dataForm = _dataAll
    },
  },
}

</script>
